<template>
    <section>
        <div class="org-tree-node" :class="[item.child.length!=0?'':'is-leaf',item.child.length!=0&&item.isHide?'collapsed':'']" v-for="(item,index) in list" :key="index">
            <div class="org-tree-node-label">
                  <!-- <el-popover
                    title="是否选为逝者"
                    width="60"
                    :disabled="isHavaDie"
                    placement='left'
                    trigger="hover"
                    > -->
                    <!-- <div>
                        <el-button type="primary" @click="confirmDie(item)">确定</el-button>
                    </div> -->
                    <div  class="org-tree-node-label-inner bg-white" :class="item.isDie?'border-color':''"> <!-- slot="reference" -->
                        <!-- 配偶 -->
                        <div class="org-tree-node-label-inner-other" v-if="item.isSpouse">
                            <input v-model="item.spouse" placeholder="配偶" class="org-tree-node-label-inner-input" maxlength=3/>
                        </div>

                        <input v-model="item.name" placeholder="姓名" class="org-tree-node-label-inner-input" maxlength=4/>
                        <!-- 添加子 -->
                        <div class="org-tree-node-label-inner-parent" v-if="!item.parents" @click="clickParent(item)">+</div>
                        <!-- 添加父 -->
                        <div class="org-tree-node-label-inner-child" @click='clickChild(item)'>+</div>
                        <!-- 添加配偶 -->
                        <div class="org-tree-node-label-inner-spouse" :class="item.isSpouse?'isHide':''"  @click='clickSpouse(item)'>+</div>
                        <!-- 折叠 -->
                        <span class="org-tree-node-btn" :class="item.isHide?'':'expanded'" v-if="item.child.length!=0" @click="changeState(item)"></span>
                    </div>
                <!-- </el-popover> -->

            </div>
            <div class="org-tree-node-children" v-if="item.child.length!=0&&!item.isHide">
                <zupu :list='item.child' :isHavaDie='isHavaDie'></zupu>
            </div>
        </div>
    </section>
</template>
<script>
export default {
    name: "zupu",
    data() {
        return {
        };
    },
    props:[
        'list','isHavaDie'
    ],
    mounted() {
    },
    methods:{
        changeState(item){
            this.$set(item,'isHide',!item.isHide);
        },
        clickParent(item){
            this.$parent.changeList();
        },
        clickChild(item){
            item.child.push({
                'child': [],
                'name': "",
                'parents': true
            });
        },
        clickSpouse(item){
            this.$set(item,'isSpouse',true);
        },
        confirmDie(item){
            this.$parent.changeIsDie();
            this.$set(item,'isDie',true);
        },
        changeIsDie(){
            this.$parent.changeIsDie();
        }
    }
};
</script>

<style scoped>
.ppp{
    position: fixed;
    left: 50px;
}
.border-color{
    border: 1px red solid;
}
.isHide{
    display: none !important;
}
.org-tree-node,
.org-tree-node-children {
    position: relative;
    margin: 0;
    padding: 0;
    list-style-type: none;
}
.org-tree-node-children:after,
.org-tree-node-children:before,
.org-tree-node:after,
.org-tree-node:before {
    transition: all 0.35s;
}
.org-tree-node-label {
    position: relative;
    display: inline-block;
    z-index: 2;
}
.org-tree-node-label .org-tree-node-label-inner {
    width: 80px;
    height: 60px;
    line-height: 60px;
    padding: 10px 0;
    text-align: center;
    border-radius: 3px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.15);
}
.org-tree-node-label-inner .org-tree-node-label-inner-input{
    height: 30px;
    width: 100%;
    font-size: 16px;
    text-align: center;
    border: none;
}
.org-tree-node-label-inner-other{
   width: 62px;
    height: 30px;
    line-height: 30px;
    bottom: -13px;
    right: -40px;
    position: absolute;
    border-radius: 3px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.15);
    background: white;
    z-index: 1;
}
.org-tree-node-label:hover .org-tree-node-label-inner-parent,
.org-tree-node-label:hover .org-tree-node-label-inner-spouse,
.org-tree-node-label:hover .org-tree-node-label-inner-child{
    display: block;
}
.org-tree-node-label .org-tree-node-label-inner-parent{
    width: 20px;
    height: 20px;
    color: white;
    margin: 0;
    font-size: 20px;
    line-height: 20px;
    text-align: center;
    background: #999999;
    position: absolute;
    top: 2px;
    left:30px; 
    cursor: pointer;
    border-radius: 50%;
    display: none;
}
.org-tree-node-label .org-tree-node-label-inner-spouse{
    width: 20px;
    height: 20px;
    color: white;
    margin: 0;
    font-size: 20px;
    line-height: 20px;
    text-align: center;
    background: #999999;
    position: absolute;
    top: 30px;
    right:0px; 
    cursor: pointer;
    border-radius: 50%;
    display: none;
}
.org-tree-node-label .org-tree-node-label-inner-child{
    width: 20px;
    height: 20px;
    color: white;
    margin: 0;
    font-size: 20px;
    line-height: 20px;
    text-align: center;
    background: #999999;
    position: absolute;
    bottom: 2px;
    left:30px; 
    cursor: pointer;
    border-radius: 50%;
    display: none;
}
.org-tree-node-btn {
    position: absolute;
    top: 100%;
    left: 50%;
    width: 20px;
    height: 20px;
    z-index: 10;
    margin-left: -11px;
    margin-top: 9px;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 50%;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.35s ease;
}
.org-tree-node-btn:hover {
    background-color: #e7e8e9;
    -webkit-transform: scale(1.15);
    transform: scale(1.15);
}
.org-tree-node-btn:after,
.org-tree-node-btn:before {
    content: "";
    position: absolute;
}
.org-tree-node-btn:before {
    top: 50%;
    left: 4px;
    right: 4px;
    height: 0;
    border-top: 1px solid #ccc;
}
.org-tree-node-btn:after {
    top: 4px;
    left: 50%;
    bottom: 4px;
    width: 0;
    border-left: 1px solid #ccc;
}
.org-tree-node-btn.expanded:after {
    border: none;
}
.org-tree-node {
    padding-top: 20px;
    display: table-cell;
    vertical-align: top;
}
.org-tree-node.collapsed,
.org-tree-node.is-leaf {
    padding-left: 30px;
    padding-right: 30px;
}
.org-tree-node:after,
.org-tree-node:before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 19px;
}
.org-tree-node:after {
    left: 50%;
    border-left: 1px solid #ddd;
}
.org-tree-node:not(:first-child):before,
.org-tree-node:not(:last-child):after {
    border-top: 1px solid #ddd;
}
.collapsable .org-tree-node.collapsed {
    padding-bottom: 30px;
}
.collapsable .org-tree-node.collapsed .org-tree-node-label:after {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    width: 50%;
    height: 20px;
    border-right: 1px solid #ddd;
}

.org-tree-node-children {
    padding-top: 20px;
    display: table;
}
.org-tree-node-children:before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 0;
    height: 20px;
    border-left: 1px solid #ddd;
}
.org-tree-node-children:after {
    content: "";
    display: table;
    clear: both;
}

</style>
